package com.wish.g1.house.service.impl;

import com.wish.g1.common.core.utils.DateUtils;
import com.wish.g1.house.entity.House;
import com.wish.g1.house.mapper.HouseMapper;
import com.wish.g1.house.service.IHouseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 房源表 服务实现类
 * </p>
 *
 * @author mayingchao
 * @since 2022-11-18
 */
@Service
public class HouseServiceImpl extends ServiceImpl<HouseMapper, House> implements IHouseService {
    @Autowired
    private HouseMapper houseMapper;

    /**
     * 查询房源
     *
     * @param id 房源主键
     * @return 房源
     */
    @Override
    public House selectHouseById(Long id)
    {
        return houseMapper.selectHouseById(id);
    }

    /**
     * 查询房源列表
     *
     * @param house 房源
     * @return 房源
     */
    @Override
    public List<House> selectHouseList(House house)
    {
        return houseMapper.selectHouseList(house);
    }

    /**
     * 新增房源
     *
     * @param house 房源
     * @return 结果
     */
    @Override
    public int insertHouse(House house)
    {
        house.setCreateTime(DateUtils.getNowDate());
        return houseMapper.insertHouse(house);
    }

    /**
     * 修改房源
     *
     * @param house 房源
     * @return 结果
     */
    @Override
    public int updateHouse(House house)
    {
        house.setUpdateTime(DateUtils.getNowDate());
        return houseMapper.updateHouse(house);
    }

    /**
     * 批量删除房源
     *
     * @param ids 需要删除的房源主键
     * @return 结果
     */
    @Override
    public int deleteHouseByIds(Long[] ids)
    {
        return houseMapper.deleteHouseByIds(ids);
    }

    /**
     * 删除房源信息
     *
     * @param id 房源主键
     * @return 结果
     */
    @Override
    public int deleteHouseById(Long id)
    {
        return houseMapper.deleteHouseById(id);
    }
}
